begintownscript;
variables;

body;

beginstate INIT_STATE;
	set_crime_tolerance(1);
	if (get_flag(1,15) == 0)	{
		message_dialog("So this is it.  This is the Cave of No Return.  You have finally arrived at your destination... but you still have to go inside and find the treasure.  This may be more difficult than it seems.","You'd best be on your guard.  After all, if this is the Cave of 'No Return' it's at least going to be dangerous.");
		set_flag(1,15,1);	}
	add_range_to_group(6,9,1);
	add_range_to_group(10,17,2);
	set_level(10,9);
	set_level(11,6);
	set_level(12,6);
	set_level(13,6);
	set_level(14,6);
	set_level(17,6);
	set_level(16,9);
	set_name(18,"Bert");
	set_name(19,"Frank");
break;

beginstate START_STATE;
	if (get_ran(1,0,100) < 1)
		text_bubble_on_char(19,"Ha! Check!");
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(19,"Your pawn is mine!");
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(19,"Maybe that was a bad move...");
	if (get_ran(1,0,100) < 1)
		text_bubble_on_char(19,"Foiled again!");
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(19,"Your army is powerless to stop me!");
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(18,"Interesting move...");
	if (get_ran(1,0,100) < 1)
		text_bubble_on_char(18,"I doubt you want to do that.");
	if (get_ran(1,0,100) < 1)
		text_bubble_on_char(18,"You shouldn't leave yourself so open.");
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(18,"Check.");
	if (get_ran(1,0,100) < 2)
		text_bubble_on_char(18,"How foolish of you.");
break;

beginstate EXIT_STATE;
break;

beginstate 10;
	if (get_flag(1,16) == 0)	{
		message_dialog("Uh-oh.  Judging from all the bones and the large rune pattern on the ground, this area is trapped.  Whatever happens when you approach is what killed a large number of creatures.","");
		set_flag(1,16,1);	}
break;

beginstate 11;
	if (get_flag(1,17) == 0)	{
		message_dialog("With your fingers crossed, you step into the center of the room.  At first it seems like nothing has happened.  Then you notice that it's getting colder, and the air is fogging up...","");
		set_terrain(24,41,2);
		set_terrain(23,41,2);
		set_terrain(25,41,2);
		set_terrain(24,31,4);
		set_terrain(27,35,19);
		set_terrain(21,35,21);
		alert_char(1001);
		set_flag(1,17,1);	}
break;

beginstate 12;
	if ((char_ok(6) && char_ok(7) && char_ok(8) && char_ok(9)) == 0) {
		set_terrain(23,41,18);
		set_terrain(24,41,18);
		set_terrain(25,41,18);
		set_terrain(24,31,20);
		set_terrain(27,35,3);
		set_terrain(21,35,5);	}
break;

beginstate 13;
	if (get_flag(1,25) == 0)	{
		force_view_center(24,19);
		force_instant_terrain_redraw();
		pause(8);
		relocate_character(10,24,13);
		force_instant_terrain_redraw();
		pause(8);
		relocate_character(10,24,14);
		force_instant_terrain_redraw();
		pause(8);
		relocate_character(10,24,15);
		force_instant_terrain_redraw();
		pause(8);
		relocate_character(10,24,16);
		force_instant_terrain_redraw();
		pause(8);
		relocate_character(10,24,17);
		force_instant_terrain_redraw();
		pause(8);
		relocate_character(10,24,18);
		force_instant_terrain_redraw();
		pause(20);
		text_bubble_on_char(10,"You...");
		force_instant_terrain_redraw();
		pause(30);
		text_bubble_on_char(10,"");
		text_bubble_on_char(10,"You're adventurers, aren't you!");
		force_instant_terrain_redraw();
		pause(26);
		text_bubble_on_char(10,"");
		text_bubble_on_char(10,"Leave!  Leave this place!");
		force_instant_terrain_redraw();
		pause(26);
		text_bubble_on_char(10,"");
		text_bubble_on_char(10,"Leave, unless you want to");
		force_instant_terrain_redraw();
		pause(15);
		text_bubble_on_char(10,"");
		text_bubble_on_char(10,"become one of us!");
		force_instant_terrain_redraw();
		pause(20);
		spawn_creature(17);
		put_effect_on_char(17,2,4,0);
		run_animation();
		pause(3);
		spawn_creature(11);
		put_effect_on_char(11,2,4,0);
		run_animation();
		text_bubble_on_char(10,"");
		force_instant_terrain_redraw();
		pause(5);
		text_bubble_on_char(11,"It's really smelly down here!");
		force_instant_terrain_redraw();
		pause(30);
		text_bubble_on_char(17,"Oy, that's just you, stinkhead!");
		force_instant_terrain_redraw();
		pause(20);
		text_bubble_on_char(11,"");
		text_bubble_on_char(11,"Call me a stinkhead, will you?");
		force_instant_terrain_redraw();
		pause(15);
		text_bubble_on_char(17,"");
		force_instant_terrain_redraw();
		pause(5);
		spawn_creature(13);
		put_effect_on_char(13,2,4,0);
		run_animation();
		pause(2);
		text_bubble_on_char(11,"");
		text_bubble_on_char(11,"Well, you're a fartface, so there!");
		force_instant_terrain_redraw();
		pause(15);
		text_bubble_on_char(17,"Ooh, you dirty little--!");
		force_instant_terrain_redraw();
		pause(20);
		text_bubble_on_char(11,"");
		force_instant_terrain_redraw();
		pause(2);
		text_bubble_on_char(10,"");
		text_bubble_on_char(10,"SHUTUP! I'm TRYING to be dramatic here!");
		text_bubble_on_char(17,"");
		force_instant_terrain_redraw();
		pause(30);
		text_bubble_on_char(10,"");
		force_instant_terrain_redraw();
		pause(20);
		text_bubble_on_char(10,"");
		text_bubble_on_char(10,"Well then, adventurers...");
		force_instant_terrain_redraw();
		pause(10);
		spawn_creature(14);
		put_effect_on_char(14,2,4,0);
		run_animation();
		pause(3);
		text_bubble_on_char(10,"");
		text_bubble_on_char(10,"If you wish to pass, kill us!");
		force_instant_terrain_redraw();
		pause(5);
		spawn_creature(16);
		put_effect_on_char(16,2,4,0);
		run_animation();
		pause(2);
		spawn_creature(12);
		put_effect_on_char(12,2,4,0);
		run_animation();
		text_bubble_on_char(10,"");
		pause(2);
		force_instant_terrain_redraw();
		spawn_creature(15);
		put_effect_on_char(15,2,4,0);
		run_animation();
		pause(5);
		text_bubble_on_char(10,"End our torturous existence!");
		force_instant_terrain_redraw();
		pause(5);
		text_bubble_on_char(12,"Yar!");
		force_instant_terrain_redraw();
		pause(15);
		set_attitude(1002,10);
		alert_char(1002);
		set_flag(1,25,1);
		force_view_center(char_loc_x(0),char_loc_y(0));	
		text_bubble_on_char(10,"");
		text_bubble_on_char(12,"");
		text_bubble_on_char(17,"");	}
break;

beginstate 14;
	set_terrain(28,35,19);
	set_terrain(27,35,19);
break;

beginstate 15;
	set_terrain(20,35,21);
	set_terrain(21,35,21);
break;

beginstate 16;
	if (get_flag(1,24) == 0)	{
		message_dialog("Strangely, you have stumbled upon some stairs here.  This indicates some form of intelligent life has been, or currently is, here.","Perhaps this is more than just a simple cave.");
		set_flag(1,24,1);	}
break;

beginstate 17;
	move_to_new_town(6,42,35);
break;

beginstate 18;
	move_to_new_town(6,34,35);
break;

beginstate 19;
	if (get_flag(3,1) == 0)	{
		message_dialog("You peer into the alcove with a start as you notice two grisly looking figures staring back at you.  Fortunately, they don't seem hostile, as one of them waves at you.  Even stranger, they are sitting at a desk playing chess.","They don't seem to care much about your presence.  They chatter cheerfully with eachother as they contemplate their next move.");
		set_flag(3,1,1);	}
break;